home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Loadstar 14
/
014.d81
/
t.sort collectio
< prev
next >
Wrap
Text File
|
2022-08-26
|
3KB
|
167 lines
SORT COLLECTION
Written by: Alan Gardner
In the never ending search for the
most efficient way to spend our
computer's time, people have put much
study and effort into designing a
faster and more efficient sorting
method. Some of the first sorts were
so slow that it could take days to
sort just a few hundred elements.
Due to the increase of knowledge in
the area of mathematical theory,
better sorting algorithms continually
arise.
SORT COLLECTION presents three
of the more popular and more efficient
sorting methods. Presented first is
a modified version of the insertion
sort. The second is the famous Shell
Sort. The third method presented is
a modification of the Shell Sort
called the Shell-Metzner. Also
included in this program is an example
of a machine-language version of the
Shell-Metzner sort.
When you run the program, you are
presented with a menu of the various
sorting methods. After chosing a
method to sort with, a random array
of 100 characters is generated. This
array is printed to the screen as the
'BEFORE' array. Next the program
begins to sort the 'BEFORE' array.
All of the sorts written in BASIC will
flash the border when an exchange is
made. The machine-language sort does
NOT flash the border. When the sort
is finished, the sorted characters
will be printed back to the screen
along with the time it took to sort
the array.
Please feel free to use any of the
sorts presented in this program in
your own programs. To use the
machine-language Shell-Metzner sort,
you must LOAD"SHELL-METZER.O",8,1.
To do this, simply put this line at
the beginning of your program:
IFX=0THENX=1:LOAD"SHELL-METZNER.O",8,1
To actually sort an array, use the
following SYS:
100 SYS49152 A$(0)
The above line will sort the array
A$ in ascending order. Be sure to use
element zero [ (0) ] when using this
SYS. For example, if CG$ was
dimensioned to 1000 [DIM CG$(1000)]
and you wanted to sort it inside of
your program, then all you would need
is:
100 SYS49152 CG$(0)
*** NOTE ***
The machine-language sort does NOT
take into account element zero when
sorting. Therefore, if element zero
is equal to "Z", then after the sort
element zero will still be equal to
"Z".
*** ANOTHER NOTE ***
The source file for SHELL-METZNER
is included on this issue of LOADSTAR.
It is saved under the name of
"SHELL-METZNER.S". It was written
with the MERLIN assembler.
>Files used: SORT COLLECTION
SHELL-METZNER.O
SHELL-METZNER.S -optional
--------------------------------------